package com.clock.web.controller.shop;

import com.clock.common.annotation.Log;
import com.clock.common.core.controller.BaseController;
import com.clock.common.core.domain.AjaxResult;
import com.clock.common.core.page.TableDataInfo;
import com.clock.common.enums.BusinessType;
import com.clock.common.utils.poi.ExcelUtil;
import com.clock.shop.domain.ShopRevenue;
import com.clock.shop.service.IShopRevenueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 流水统计Controller
 * 
 * @author ruoyi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/shop/revenue")
public class ShopRevenueController extends BaseController
{
    @Autowired
    private IShopRevenueService shopRevenueService;

    /**
     * 查询流水统计列表
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopRevenue shopRevenue)
    {
        startPage();
        List<ShopRevenue> list = shopRevenueService.selectShopRevenueList(shopRevenue);
        return getDataTable(list);
    }

    /**
     * 导出流水统计列表
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:export')")
    @Log(title = "流水统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopRevenue shopRevenue)
    {
        List<ShopRevenue> list = shopRevenueService.selectShopRevenueList(shopRevenue);
        ExcelUtil<ShopRevenue> util = new ExcelUtil<ShopRevenue>(ShopRevenue.class);
        util.exportExcel(response, list, "流水统计数据");
    }

    /**
     * 获取流水统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:query')")
    @GetMapping(value = "/{revenueId}")
    public AjaxResult getInfo(@PathVariable("revenueId") Long revenueId)
    {
        return success(shopRevenueService.selectShopRevenueByRevenueId(revenueId));
    }

    /**
     * 新增流水统计
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:add')")
    @Log(title = "流水统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopRevenue shopRevenue)
    {
        return toAjax(shopRevenueService.insertShopRevenue(shopRevenue));
    }

    /**
     * 修改流水统计
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:edit')")
    @Log(title = "流水统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopRevenue shopRevenue)
    {
        return toAjax(shopRevenueService.updateShopRevenue(shopRevenue));
    }

    /**
     * 删除流水统计
     */
    @PreAuthorize("@ss.hasPermi('shop:revenue:remove')")
    @Log(title = "流水统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{revenueIds}")
    public AjaxResult remove(@PathVariable Long[] revenueIds)
    {
        return toAjax(shopRevenueService.deleteShopRevenueByRevenueIds(revenueIds));
    }
}
